package recite.word.client.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import recite.word.client.dto.user.GetUserDayDTO;
import recite.word.client.service.IUserService;
import recite.word.client.vo.plan.CalendarData;
import recite.word.client.vo.user.GetPunchVO;
import recite.word.client.vo.user.GetUserDayVO;
import recite.word.client.vo.user.GetUserInfoVO;
import recite.word.service.base.common.request.BaseRequest;
import recite.word.service.base.common.response.ResponseResult;

import java.util.List;

@RestController
@RequestMapping("/client/user")
@Api(tags = "客户端【用户】controller")
public class UserController {
    @Autowired
    private IUserService userService;

    @PostMapping("/getPunch")
    @ApiOperation("获取打卡数据")
    public ResponseResult<GetPunchVO> getPunch(){
        GetPunchVO ans = userService.getPunch();
        return ResponseResult.success(ans);
    }

    @PostMapping("/getInfo")
    @ApiOperation("获取个人信息")
    public ResponseResult<GetUserInfoVO> getInfo(){
        GetUserInfoVO ans = userService.getInfo();
        return ResponseResult.success(ans);
    }

    @PostMapping("/getDayInfo")
    @ApiOperation("获取某日打卡信息")
    public ResponseResult<GetUserDayVO> getDayInfo(@RequestBody BaseRequest<GetUserDayDTO> dto){
        GetUserDayVO ans = userService.getDayInfo(dto);
        return ResponseResult.success(ans);
    }

    @PostMapping("/getPunchContinue")
    @ApiOperation("获取连续打卡天数")
    public ResponseResult<Integer> getPunchContinue(){
        Integer ans = userService.getPunchContinue();
        return ResponseResult.success(ans);
    }

    @PostMapping("/getPunchMonth")
    @ApiOperation("获取当月打卡日期")
    public ResponseResult<List<CalendarData>> getPunchMonth(){
        List<CalendarData> ans = userService.getPunchMonth();
        return ResponseResult.success(ans);
    }
}
